import { fileURLToPath, URL } from 'url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [
    vue(),
  ],
  base: './',
  resolve: {
    alias: {
      // '@': fileURLToPath(new URL('./src', import.meta.url))
      '@': path.resolve(__dirname, './src')
    }
  },
  server: {
    open: true,
    port: 5000,
    host: '0.0.0.0',
    hmr: true,
    proxy: {
      '/api': {
        target: 'http://localhost:1130',
        // target: 'http://124.70.20.171:1130',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/astar': {
        target: 'http://localhost:1009',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/astar/, '')
      },
      '/uli': {
        target: 'http://www.wzhy.com.cn:8000/jxhyb/sequence/surgeList',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/uli/, '')
      },
      '/ybd': {
        target: 'http://localhost:8090',
        // target:'http://www.wzhy.com.cn:8000/ybdtest',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/ybd/, '')
      },
      // '/gif': {
      //   target: 'http://39.103.180.154:1007',
      //   changeOrigin: true,
      //   rewrite: (path) => path.replace(/^\/gif/, '')
      // },
      '/gif': {
        target: 'http://www.wzhy.com.cn:8000/jxhyb-1.0',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/gif/, '')
      },
      '/nwg': {
        target: 'http://192.168.1.205:9005',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/nwg/, '')
      },
      '/nwj': {
        target: 'http://192.168.1.205:8000/ybd',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/nwj/, '')
      },
      '/jxh': {
        target: 'http://wzhy.com.cn:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/jxh/, '')
      }
    }
  },
  build: {
    chunkSizeWarningLimit: 20000
  },
})
